local PageViewMark = class("PageViewMark",function()
    return display.newNode();
end);
function PageViewMark:ctor(args)
    local pageCount = args.count or 1;
    local bgName = mgrs.res:getPngPath(args.mark1png or "dian1");
    local markName = mgrs.res:getPngPath(args.mark2png or "dian2");
    local Image = {
        off = bgName,
        off_pressed = bgName,
        off_disabled = bgName,
        on = markName,
        on_pressed = markName,
        on_disabled = markName,
    }
    self.group = cc.ui.UICheckBoxButtonGroup.new(display.LEFT_TO_RIGHT);
    for i=1,pageCount do
        local checkBoxButton = cc.ui.UICheckBoxButton.new(Image);
        self.group:addButton(checkBoxButton);
    end
    --self.group:setButtonsLayoutMargin(10, 10, 0, 0);
    
    local sp = display.newSprite(bgName);
    local size = sp:getContentSize();
    local variable;

    
    self:setContentSize(cc.size(size.width * pageCount ,size.height));
    self:ignoreAnchorPointForPosition(false);
    self:setAnchorPoint(cc.p(0.5,0.5));
    self:addChild(self.group);
   
    self:setSelectedIndex(1);
    self:setMarkEnable(false);
    
end

function PageViewMark:setMarkEnable(enable)
    for i = 1,self.group:getButtonsCount() do
        local button = self.group:getButtonAtIndex(i);
        button:setTouchEnabled(enable);
    end
end

function PageViewMark:setSelectedIndex(index)
    if index < 1 or index > self.group:getButtonsCount() then
        return;
    end
    self.group:getButtonAtIndex(index):setButtonSelected(true);
end

function PageViewMark:setMarkClickCbk(cbk)
    self:setMarkEnable(true);
    self.group:onButtonSelectChanged(function(event)
        if cbk then
            cbk(event.selected);
        end
    end)
end

return PageViewMark;

--endregion
